package com.example.studentknowledgesys.controller;

import com.example.studentknowledgesys.entity.PointRecord;
import com.example.studentknowledgesys.service.PointService;
import com.example.studentknowledgesys.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/point-records")
public class PointRecordController {
    @Autowired
    private PointService pointService;
    // 获取用户积分记录
    @GetMapping("/user/{userId}")
    public Result getUserPointRecords(@PathVariable Long userId) {
        List<PointRecord> records = pointService.getUserPointRecords(userId);
        return Result.success(records);
    }

    // 获取所有积分记录
    @GetMapping
    public Result getAllPointRecords() {
        List<PointRecord> records = pointService.getAllPointRecords();
        return Result .success(records);
    }
}
